package org.nobody.mallb2c.mallsearch.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

/**
 * @author 3489309323@qq.com
 * @create 2020-09-01-10:34
 */
@SpringBootConfiguration
public class MallElasticSearchConfig {
  public static final RequestOptions COMMON_OPTIONS;

  static {
    RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();

    COMMON_OPTIONS = builder.build();
  }

  @Bean
  public RestHighLevelClient esRestClient(){
    return new RestHighLevelClient(
      RestClient.builder(
        new HttpHost("localhost",9200,"http")
        //如果有集群↓
        //,new HttpHost("localhost",9200,"http")
      )
    );
  }
}
